package model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import controller.ConnectDB;
import controllerBeans.Cliente;

public class ClienteDAO {

	private Connection connection;
	public ClienteDAO(){
	
	}
	
	public void create(Cliente cliente){
		
		String sqlInsert = "INSERT INTO usuario (email, nome, senha, endereco, " +
				"sexo, cpf, rg, telefone, tipo) VALUES (?,?,?,?,?,?,?,?,?)";
		
		try {
			this.connection = new ConnectDB().getConnection();
			PreparedStatement stmt = connection.prepareStatement(sqlInsert);
			
			stmt.setString(1, cliente.getEmail());
			stmt.setString(2, cliente.getNome());
			stmt.setString(3, cliente.getSenha());
			stmt.setString(4, cliente.getEndereco());
			stmt.setString(5, cliente.getSexo());
			stmt.setString(6, cliente.getCpf());
			stmt.setString(7, cliente.getRg());
			stmt.setString(8, cliente.getTelefone());
			stmt.setInt(9, cliente.getTipo());
			stmt.execute();
			stmt.close();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
}
